feat: add streaming response support for ReActAgent and DeepAgent - #7
Conversation
- Add ReplyStream() method to ReActAgent and DeepAgent for progressive response streaming - Implement thinkAndActStream() internal method using model.Stream() API - Support tool calling, interruption, and tracing in streaming mode - Add comprehensive unit tests with mock streaming model - Create 5 example programs demonstrating various streaming scenarios: * agent_stream: basic streaming usage * stream_with_tools: streaming with tool integration * stream_comparison: performance comparison between streaming and non-streaming * interactive_stream: interactive CLI chat with streaming * deep_agent_stream: advanced DeepAgent features with streaming - Add complete documentation and usage guides All tests pass with race detection enabled. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (11)
📝 WalkthroughWalkthroughAgentScope-Go streaming output implementation adds ReplyStream and thinkAndActStream methods to ReActAgent and DeepAgent, enabling real-time token-by-token response streaming over channels. Includes full test coverage, comprehensive documentation of the implementation and architecture, and five example programs demonstrating streaming across basic, tool-based, comparative, interactive, and advanced DeepAgent scenarios. ChangesCore Streaming Implementation & Testing
Streaming Usage Examples & User Guide
Sequence DiagramsequenceDiagram
participant Client
participant ReplyStream as ReplyStream<br/>(goroutine)
participant thinkAndActStream
participant Model
participant Channel as Channel<br/>(buffered)
Client->>ReplyStream: ReplyStream(ctx, msg)
ReplyStream->>ReplyStream: setup memory & hooks
ReplyStream->>ReplyStream: spawn background goroutine
activate ReplyStream
loop Agent Iterations
ReplyStream->>thinkAndActStream: invoke
activate thinkAndActStream
thinkAndActStream->>Model: Stream()
activate Model
loop Streamed Chunks
Model->>thinkAndActStream: ChatResponse chunk
thinkAndActStream->>Channel: emit partial *message.Msg
end
Model->>thinkAndActStream: stream complete
deactivate Model
thinkAndActStream->>thinkAndActStream: persist final assistant msg
alt Tool Use Detected
thinkAndActStream->>thinkAndActStream: execute tools
thinkAndActStream->>Channel: emit tool result msg
end
deactivate thinkAndActStream
end
ReplyStream->>Channel: close channel
deactivate ReplyStream
Client->>Channel: receive <-chan *message.Msg
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
All tests pass with race detection enabled.
Summary by CodeRabbit
Release Notes
New Features
Documentation